/*
 * @Author: your name
 * @Date: 2024-05-31 11:49:43
 * @LastEditTime: 2024-05-31 11:55:28
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \.leetcode\406.根据身高重建队列.cpp
 */
/*
 * @lc app=leetcode.cn id=406 lang=cpp
 *
 * [406] 根据身高重建队列
 */

// @lc code=start
class Solution {
public:
    static bool cmp(vector<int>&A, vector<int>&B){
        if(A[0] == B[0]){
            return A[1] < B[1];
        }
        return A[0] > B[0];
    }
    vector<vector<int>> reconstructQueue(vector<vector<int>>& people) {
        sort(people.begin(), people.end(), cmp);
        vector<vector<int>> que;
        for (int i = 0; i < people.size(); i++)
        {
            que.insert(que.begin()+people[i][1], people[i]);
        }
        return que;
    }
};
// @lc code=end

